package com.yanqu.road.server.cmd.activity.seacraftsouthsea;

import com.yanqu.road.pb.activity.SeacraftSouthSeaProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.seacraftsouthsea.SeacraftSouthSeaMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2022/1/20 17:21
 */
@Cmd(code = CrossProtocol.C2_SEACRAFT_SOUTH_SEA_GET_BATTLE_RECORD_RANK, desc = "海上争霸 南海丝路 查看船只攻防信息")
public class CrossSeacraftSouthSeaGetBattleRecordCmd extends CrossUnionCommand {
    long userId;
    int activityId;
    int type;
    String unionId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SeacraftSouthSeaProto.SeacraftSouthSeaGetBattleRecordReqMsg reqMsg = SeacraftSouthSeaProto.SeacraftSouthSeaGetBattleRecordReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        unionId = reqMsg.getUnionId();
        type = reqMsg.getType();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        MessageHelper.sendPacket(serverId, userId, YanQuMessageUtils.buildMessage(ClientProtocol.U_SEACRAFT_SOUTH_SEA_GET_BATTLE_RECORD_RANK, SeacraftSouthSeaMgr.getBattleRecord(activityId,unionId, type)));
    }

    @Override
    public void sendData() {

    }
}
